package com.bjsxt.ego.goods.pojo;

import java.util.Date;

import org.junit.Test;

import com.alibaba.fastjson.JSONArray;
import com.bjsxt.ego.common.util.ConstatFinalUtil;
import com.bjsxt.ego.users.pojo.Admins;

/**
 * 商品的pojo类
 * 
 * @author 章鸿敏
 *
 */
public class Goods
{
	private int id; // 主键
	private int adminsId; // 管理员id
	private int cateId; // 分类id
	private int brandId; // 品牌id
	private String name; // 名称 前台用户显示
	private String title; // 标题_管理员显示
	private String url; // 唯一标识,在url上显示
	private double weight; // 重量
	private String content; // 内容介绍
	private int saleNum; // 销售量
	private int remainNum; // 库存量
	private double marketPrice; // 市场价
	private double price; // 折扣价(真实价)
	private String listImgPath; // 列表图片
	private String imgs; // 图库(json)
	private String spec; // 规格(json)
	private byte status; // 状态:0：禁用 1：启用
	private Date createTime; // 创建时间
	private Date updateTime; // 更新时间
	private Date pubTime; // 发布时间

	/* 字符串描述 */
	private String statusStr;
	private String remainNumStr;
	private JSONArray imgsArr = new JSONArray();

	/* 关联对象 */
	private Admins admins;
	private GoodsCategory goodsCategory;
	private GoodsBrand goodsBrand;

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getAdminsId()
	{
		return adminsId;
	}

	public void setAdminsId(int adminsId)
	{
		this.adminsId = adminsId;
	}

	public int getCateId()
	{
		return cateId;
	}

	public void setCateId(int cateId)
	{
		this.cateId = cateId;
	}

	public int getBrandId()
	{
		return brandId;
	}

	public void setBrandId(int brandId)
	{
		this.brandId = brandId;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getTitle()
	{
		return title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

	public String getUrl()
	{
		return url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	public double getWeight()
	{
		return weight;
	}

	public void setWeight(double weight)
	{
		this.weight = weight;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public int getSaleNum()
	{
		return saleNum;
	}

	public void setSaleNum(int saleNum)
	{
		this.saleNum = saleNum;
	}

	public int getRemainNum()
	{
		return remainNum;
	}

	public void setRemainNum(int remainNum)
	{
		this.remainNum = remainNum;
	}

	public double getMarketPrice()
	{
		return marketPrice;
	}

	public void setMarketPrice(double marketPrice)
	{
		this.marketPrice = marketPrice;
	}

	public double getPrice()
	{
		return price;
	}

	public void setPrice(double price)
	{
		this.price = price;
	}

	public String getListImgPath()
	{
		return listImgPath;
	}

	public void setListImgPath(String listImgPath)
	{
		this.listImgPath = listImgPath;
	}

	public String getImgs()
	{
		return imgs;
	}

	public void setImgs(String imgs)
	{
		this.imgs = imgs;
	}

	public String getSpec()
	{
		return spec;
	}

	public void setSpec(String spec)
	{
		this.spec = spec;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public Admins getAdmins()
	{
		return admins;
	}

	public void setAdmins(Admins admins)
	{
		this.admins = admins;
	}

	public GoodsCategory getGoodsCategory()
	{
		return goodsCategory;
	}

	public void setGoodsCategory(GoodsCategory goodsCategory)
	{
		this.goodsCategory = goodsCategory;
	}

	public GoodsBrand getGoodsBrand()
	{
		return goodsBrand;
	}

	public void setGoodsBrand(GoodsBrand goodsBrand)
	{
		this.goodsBrand = goodsBrand;
	}

	/**
	 *  对状态显示进行处理
	 * @return
	 */
	public String getStatusStr()
	{
		/**
		 * 状态：0：禁用1：启用
		 */
		GoodsEnum[] goodsEnums = GoodsEnum.values();
		for (int i = 0; i < goodsEnums.length; i++)
		{
			GoodsEnum goodsEnum = goodsEnums[i];
			if (goodsEnum.toString().startsWith("STATUS_"))
			{
				if (goodsEnum.getStatus() == this.status)
				{
					this.statusStr = goodsEnum.getInfo();
					break;
				}
			}
		}
		return statusStr;
	}

	/**
	 *  对库存显示进行处理
	 * @return
	 */
	public String getRemainNumStr()
	{
		if (this.remainNum >0)
		{
			this.remainNumStr = "有货,可以当日发货";
		}else
		{
			this.remainNumStr = "暂时缺货";
		}
		return remainNumStr;
	}

	public JSONArray getImgsArr()
	{
		return imgsArr;
	}
	
}
